@echo off


@REM 数据库备份
@REM 作者: x
@REM 时间: 2024-03

@REM 设置连接信息
set host=121.29.1.171
set port=13306
set user=root
set pass=Dev@sd123

@REM 设置要备份的MySql数据库名称
set dbname=dx_upm


set hour=%time:~0,2%
if "%time:~0,1%"==" " set hour=0%time:~1,1%

set backup_date=%Date:~0,4%%Date:~5,2%%Date:~8,2%%hour%%Time:~3,2%%Time:~6,2%

@REM 设置备份文件的路径
set backupfile=D:\backData\%dbname%-%backup_date%.sql

"D:\Program Files\MySQL\MySQL Server 8.1\bin\mysqldump" -h%host% -P%port% -u%user% -p%pass% -c --add-drop-table %dbname% > %backupfile%

pause

